package com.gopay.common.cps.dao.wallet.tyy.impl;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.cps.dao.wallet.tyy.WaTyyInviteInfoDao;
import com.gopay.common.domain.dps.WaTyyInviteInfo;
/**
 * 天溢盈邀请记录信息
 * @author ZHOUPENG
 * @date   2017年4月16日 下午4:54:16
 */
@Repository("waTyyInviteInfoDao")
public class WaTyyInviteInfoDaoImpl extends BaseDAOImpl<WaTyyInviteInfo, Serializable> implements WaTyyInviteInfoDao {

    @Override
    public int findCountByIsRegister(String isRegister) {
        String sql = "  from Wa_Tyy_Invite_Info where is_Register = :isRegister and invite_Status = :inviteStatus ";
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("isRegister", isRegister);
        param.put("inviteStatus", "1");
        return findCountBySql(sql, param);
    }
    
    /**
     * 根据注册标识查询已注册/未注册的数据
     * @param isRegister
     * @return
     */
    @Override
    public List<WaTyyInviteInfo> findByIsRegister(String isRegister, int pageIndex, int pageSize) {
        String hql = " from WaTyyInviteInfo where isRegister = :isRegister and inviteStatus = :inviteStatus ";
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("isRegister", isRegister);
        param.put("inviteStatus", "1");
        return findByHql(hql, param,pageIndex,pageSize);
    }
    
    @Override
    public int findCountByIviteStatus(String inviteStatus) {
//        String hql = " from WaTyyInviteInfo where inviteStatus = :inviteStatus ";
        String sql = " from Wa_Tyy_Invite_Info where invite_Status = :inviteStatus and is_Register = :isRegister ";
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("inviteStatus", inviteStatus);
        param.put("isRegister", "1");
        return findCountBySql(sql, param);
    }
    
    /**
     * 根据注册标识查询已注册/未注册的数据
     * @param isRegister
     * @return
     */
    @Override
    public List<WaTyyInviteInfo> findByIviteStatus(String inviteStatus, int pageIndex, int pageSize) {
        String hql = " from WaTyyInviteInfo where inviteStatus = :inviteStatus and isRegister = :isRegister ";
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("inviteStatus", inviteStatus);
        param.put("isRegister", "1");
        return findByHql(hql, param,pageIndex,pageSize);
    }
    
    /**
     * 根据受邀人ID查询状态为邀请成功的数据
     * @param isRegister
     * @return
     */
    @Override
    public List<WaTyyInviteInfo> findByReceiveCustId(String receiveCustId) {
        String hql = " from WaTyyInviteInfo where receiveCustId = :receiveCustId and inviteStatus = :inviteStatus ";
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("receiveCustId", receiveCustId);
        param.put("inviteStatus", "1");
        return findByHql(hql, param);
    }
    
    
}
